<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>练习</title>
    <script>
        function f1(){
            // 取出文本框中输入的数据
            let inText = document.getElementById("inText").value;
            // 创建li
            let li = document.createElement("li");
            // 创建文本节点
            let text = document.createTextNode(inText);

            li.appendChild(text);
            let u = document.getElementById("u");
            u.appendChild(li);
        }
    </script>
</head>
<body>
<input type="text" id="inText">
<button onclick="f1()">追加</button>
<ul id="u">
    <li>item1</li>
    <li>item2</li>
    <li>item3</li>
</ul>
</body>
</html>